package cn.qyd.aqs;

import java.util.Optional;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author 邱运铎
 * @date 2024-03-20 10:41
 */
public class ConditionDemo {
    public static void main(String[] args) throws InterruptedException {
        Lock lock = new ReentrantLock();
        Condition condition = lock.newCondition();
        lock.lock();
        try  {
//            lock.notify();
            condition.signal();
        } finally {
            lock.unlock();
        }


        String str = null;
        Optional<String> optional = Optional.ofNullable(str);
        optional.ifPresent(System.out::println);
        System.out.println(optional.orElseGet(() -> "null"));
        optional.ifPresent(System.out::println);
    }
}
